import { GET, POST, DELETE, UPLOAD } from '@http/index';

// 查询茶种列表
export function list(params) {
  return GET({
    url: '/teaManagement/backFindAllTeaListMessage',
    params
  });
}

// 添加茶种

// 查询所有茶种图片类别
export function findAllVariety() {
  return GET({
    url: '/teaManagement/findAllVariety'
  });
}

// 上传封面图片
export function uploadOtherImg(data) {
  return UPLOAD({
    url: '/file/uploadOtherImg',
    data
  });
}

// 上传备注图片
export function uploadBackImg({ data, params }) {
  return UPLOAD({
    url: '/file/uploadOtherImg',
    params,
    data
  });
}

// 删除备注图片 /file/deleteOtherImg
export function deleteBackImg(id) {
  return DELETE({
    url: '/file/deleteOtherImg',
    params: {
      id
    }
  });
}

// 上传茶种种类图片 // 芽、叶、单株
export function uploadTeaImg({ data, params }) {
  return UPLOAD({
    url: '/file/uploadTeaImg',
    params,
    data
  });
}

// 删除茶种种类图片 // 芽、叶、单株 /file/deleteOtherImg
export function deleteTeaImg(id) {
  return DELETE({
    url: '/file/deleteTeaImg',
    params: {
      id
    }
  });
}

// 添加茶种
export function addMessage(data) {
  return POST({
    url: '/teaManagement/backAddNewTeaVariety',
    data
  });
}

// 删除茶种
export function deleteTea(data) {
  return DELETE({
    url: '/teaManagement/backDeleteTeaMessageById',
    data
  });
}

// 获取茶种信息
export function getUpdateMessage(params) {
  return GET({
    url: '/teaManagement/backFindTeaDetailsMessageById',
    params
  });
}

// 获取备注信息
export function getUpdateRemarks(params) {
  return GET({
    url: '/teaManagement/backFindRemarksTeaDetailsMessageById',
    params
  });
}

// 修改备注信息
export function updateRemarks({ data, teaId }) {
  console.log(data);
  if (data) {
    data.forEach(item => {
      item.teaMessageId = teaId;
    });
  }
  console.log(data);
  return POST({
    url: '/teaManagement/backUpdateTeaRemarksMessageById',
    data
  });
}

// 修改茶种信息
export function updateMessage(data) {
  data.ids = data.imgIds;
  delete data.imgIds;
  return POST({
    url: '/teaManagement/backUpdateTeaMessageById',
    data
  });
}

// 下载全部茶种信息二维码
export function downloadAll({ config }) {
  return POST({
    url: '/code/downloadAllTeaQrCodeByIds',
    ...config
  });
}

// 批量下载茶种信息二维码
export function batchDownload({ data, config }) {
  return POST({
    url: '/code/downloadTeaQrCodeByIds',
    data,
    ...config
  });
}
